package com.cmcc.linlaker.ui.upload;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.cmcc.linlaker.R;
import com.cmcc.linlaker.ui.query.adapter.QueryPageAdapter;
import com.cmcc.linlaker.ui.upload.fragment.UploadOtherFragmentNew;
import com.cmcc.linlaker.ui.upload.fragment.UploadProjectFragment;
import com.cmcc.linlaker.utils.BarUtils;

import java.util.ArrayList;
import java.util.List;

public class NewUploadQuestionActivity2 extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_new_upload2);

        BarUtils.initStatusBar(this);

        initView();
    }

    private TabLayout indicator;
    private ViewPager mViewPager;
    private QueryPageAdapter pagerAdapter;

    private void initView() {

        initPagerAdapter();

        mViewPager = findViewById(R.id.view_pager);
        mViewPager.setOffscreenPageLimit(2);
        indicator = findViewById(R.id.indicator);
        mViewPager.setAdapter(pagerAdapter);
        indicator.setTabMode(TabLayout.MODE_FIXED);
        indicator.setupWithViewPager(mViewPager);
    }

    private String[] titles = {"临湖建设项目", "综合巡查事项"};
    private List<Fragment> fragmentList;

    /**
     * 初始化pagerAdpter
     */
    private void initPagerAdapter() {
        fragmentList = new ArrayList<>();
        fragmentList.add(UploadProjectFragment.newInstance());
        fragmentList.add(UploadOtherFragmentNew.newInstance());

        pagerAdapter = new QueryPageAdapter(getSupportFragmentManager(), titles, fragmentList);
    }

    public void back(View view) {
        finish();
    }


}
